//
//  WTLiveSDK.m
//  WTLiveSDKDemo
//
//  Created by ben on 16/9/26.
//  Copyright © 2016年 ben. All rights reserved.
//

#import "WTLiveSDK.h"


@interface WTLiveSDK ()

@property (nonatomic,weak) id<WTLoginManager> loginManager;
@property (nonatomic,weak) id<WTChatManager>  chatManager;
@property (nonatomic,weak) id<WTChatRoomManager>  chatRoomManager;

@property (nonatomic,strong) WTLoginManagerHandle*  loginManagerHandle;
@property (nonatomic,strong) WTChatManagerHandle*   chatManagerHandle;
@property (nonatomic,strong) WTChatRoomManagerHandle*   chatRoomManagerHandle;
@end


@implementation WTLiveSDK

+ (instancetype)shareSDK{
    
    static WTLiveSDK * sdk = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sdk = [WTLiveSDK new];
    });
    return sdk;
}

- (instancetype)init{
    
    self = [super init];
    if (self) {

        self.loginManager = (id<WTLoginManager>)self.loginManagerHandle;
        
        self.chatManager = (id<WTChatManager>)self.chatManagerHandle;
        
        self.chatRoomManager = (id<WTChatRoomManager>)self.chatRoomManagerHandle;
    }
    return self;
}

- (void)registerWithAppID:(NSString *)appKey
                  cerName:(NSString *)cerName{
    
    [[NIMSDK sharedSDK] registerWithAppID:appKey cerName:cerName];
}


#pragma mark getter
- (WTLoginManagerHandle *)loginManagerHandle{
    
    if(!_loginManagerHandle){
        _loginManagerHandle = [[WTLoginManagerHandle alloc] init];
    }
    return _loginManagerHandle;
}

- (WTChatManagerHandle *)chatManagerHandle{
    if(!_chatManagerHandle){
        _chatManagerHandle = [[WTChatManagerHandle alloc] init];
    }
    return _chatManagerHandle;
}

- (WTChatRoomManagerHandle *)chatRoomManagerHandle{
    
    if(!_chatRoomManagerHandle){
        _chatRoomManagerHandle = [[WTChatRoomManagerHandle alloc] init];
    }
    return _chatRoomManagerHandle;
}

@end
